﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>APP加载页面</title>
    <!-- Bootstrap -->

    <link href="/CSS/bootstrap3.3.5/css/bootstrap.css" rel="stylesheet">
    <link href="/CSS/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
    <style>
        .edui-container > * {
            box-sizing: content-box;
        }/*解决UMEDIT在boot下不能改变图片大小的问题*/
    </style>
    <link href="/CSS/Base/BaseClass.css?cssver=4" rel="stylesheet" type="text/css" />
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="/Scripts/jquery-1.11.2.min.js"></script>
    <script src="/Scripts/jquery-migrate-1.1.0.min.js"></script>
    <script src="/JqueryPlug/layer/layer/layer.js"></script>
    <script src="/Scripts/avalon1.5.js"></script>
    <script src="/CSS/bootstrap3.3.5/js/bootstrap.js"></script>
    <script src="/Scripts/SZHLCommon.js?jsver=5"></script>
    <style>
        .pCard {
            min-width: 80px;
            text-align: center;
            margin: 0 5px 5px 5px;
        }

        .fa-spin {
            -webkit-animation: fa-spin 2s infinite linear;
            animation: fa-spin 2s infinite linear;
        }

        @-webkit-keyframes fa-spin {
            0% {
                -webkit-transform: rotate(0deg);
                transform: rotate(0deg);
            }

            100% {
                -webkit-transform: rotate(359deg);
                transform: rotate(359deg);
            }
        }

        @keyframes fa-spin {
            0% {
                -webkit-transform: rotate(0deg);
                transform: rotate(0deg);
            }

            100% {
                -webkit-transform: rotate(359deg);
                transform: rotate(359deg);
            }
        }
    </style>
    <script>
        var pmodel = avalon.define({
            $id: "APP_ADD",
            nowuser: ComFunJS.getnowuser(),
            FormCode: ComFunJS.getQueryString("FormCode"),
            DataID: ComFunJS.getQueryString("ID"),
            PIID: ComFunJS.getQueryString("PIID"),//流程ID
            PDID: ComFunJS.getQueryString("PDID"),//流程配置ID
            pageType: ComFunJS.getQueryString("pageType"),//页面类型：edit:修改,view:查看页面
            PIMODEL: {},//流程数据
            TASKDATA: [],//任务数据
            USERDATA: [],//任务数据
            iscansp: false,//是否有处理单据权限
            lctype: ComFunJS.getQueryString("LCTYPE", "-1"),//流程类型-1:没有流程,0:自由流程1:固定流程
            spReason: "同意",//默认审批意见
            render: function () {
                if (tempmodel) {
                    tempmodel.inittemp(pmodel.DataID);
                    if (pmodel.lctype == 0 && (pmodel.FormCode != "LCSP" || (pmodel.PIID || pmodel.PDID))) {//不是自定义流程审批获取审核人用FormCode,否则用pmodel.PIID或者pmodel.PDID
                        pmodel.getSHUser();//如果有流程,则获取审核人
                    }
                    var index = parent.layer.getFrameIndex(window.name)
                    parent.layer.title(tempmodel.name, index)
                }
                avalon.templateCache = null;
                if (pmodel.PIID) {//如果有流程ID,获取流程数据
                    pmodel.getwfdata();
                }
            },
            getwfdata: function () {
                $.getJSON("/API/FTAPI.ashx?ACTION=GETWFDATA", { P1: pmodel.PIID }, function (result) {
                    if (result.ErrorMsg == "") {
                        pmodel.PIMODEL = result.Result;//流程数据
                        pmodel.TASKDATA = result.Result1;//任务数据
                        pmodel.iscansp = result.Result2 == "Y";//判断当前用户是否具有审批权限
                        pmodel.lctype = result.Result3;//流程类型

                    }
                });
            },
            getSHUser: function () {
                $.getJSON("/API/FTAPI.ashx?ACTION=GETSPUSERLIST", { P1: pmodel.FormCode, PDID: pmodel.PDID, PIID: pmodel.PIID }, function (result) {
                    if (result.ErrorMsg == "") {
                        pmodel.USERDATA = result.Result;
                    }
                });
            },//获取具有审核权限的人员
            SaveData: function (dom, isjp) {

                var piframe = parent.$("iframe:visible")[0];
                var errmsg = "";
                errmsg = pmodel.CheckData();
                if (errmsg) {
                    layer.tips(errmsg, dom);
                }
                else {
                    if ((pmodel.lctype != "-1" && pmodel.pageType == "edit") || pmodel.lctype == "-1") {//如果是不带流程的表单或者页面类型是编辑的表单,直接保存
                        tempmodel.SaveData($(dom));
                        piframe.contentWindow.location.reload()
                        setTimeout("parent.layer.closeAll()", 1000)
                        localStorage.setItem(pmodel.FormCode, "")//清除缓存
                    }
                    else {
                        if ((pmodel.lctype == "0" && $("#conshr").val()) || pmodel.lctype == "1") {//如果是自由流程,需要选择审核人
                            $(dom).addClass("disabled").attr("disabled", true).find("i").show();//加上转圈样式
                            $.getJSON("/API/FTAPI.ashx?ACTION=STARTWF", { P1: pmodel.FormCode, P2: $("#conshr").val(), PDID: pmodel.PDID }, function (result) {
                                if ($.trim(result.ErrorMsg) == "") {
                                    tempmodel.SaveData($(dom), result.Result.PIID);
                                    setTimeout("location.reload()", 1000)
                                    piframe.contentWindow.location.reload()
                                    localStorage.setItem(pmodel.FormCode, "")//清除缓存
                                }
                            });
                        } else {
                            ComFunJS.winwarning("请选择审核人");
                        }


                    }
                }
            },
            CheckData: function () {
                var retmsg = "";
                if ($(".szhl_require")) {
                    $(".szhl_require:visible, .szhl_Int:visible, .szhl_Phone:visible").each(function () {
                        if ($(this).hasClass("szhl_UEEDIT") && $(this).hasClass("szhl_require") && ($(this).prop("tagName") == "DIV" && $(this).text() == "")) {
                            retmsg = $(this).parent().parent().parent().parent().find("label").text() + "不能为空";
                        }
                        else if ($(this).val() == "" && $(this).hasClass("szhl_require") && !$(this).hasClass("szhl_UEEDIT")) {
                            retmsg = $(this).parent().prev("label").text() + "不能为空";
                        } else if ($(this).hasClass("szhl_Int")) {
                            if ($(this).val() == "") {
                                retmsg = $(this).parent().prev("label").text() + "不能为空";
                            }
                            if (!(/^[0-9]*$/.test($(this).val()))) {
                                retmsg = $(this).parent().prev("label").text() + "必须是数字";
                            }
                        }
                        else if ($(this).hasClass("szhl_Phone")) {
                            if ($(this).val() == "") {
                                retmsg = $(this).parent().prev("label").text() + "不能为空";
                            }
                            if (!(/^0?1[3|4|7|5|8][0-9]\d{8}$/.test($(this).val()))) {
                                retmsg = $(this).parent().prev("label").text() + "填写不正确";
                            }
                        }
                        if (retmsg != "") {
                            return false;
                        }

                    })
                }
                return retmsg;
            },
            rebackform: function () {
                if (pmodel.spReason == "同意") {
                    pmodel.spReason = "退回";
                }
                $.post("/API/FTAPI.ashx?ACTION=REBACKWF", { P1: pmodel.PIID, P2: pmodel.spReason, ID: pmodel.DataID, formcode: pmodel.FormCode }, function (result) {
                    var result = $.parseJSON(result)
                    if ($.trim(result.ErrorMsg) == "") {
                        ComFunJS.winsuccess("退回成功");
                        setTimeout("location.reload()", 1000);
                    }
                });
            },//退回表单
            managetask: function () { //固定流程的处理
                $.post("/API/FTAPI.ashx?ACTION=MANAGEWF", { P1: pmodel.PIID, P2: pmodel.spReason, ID: pmodel.DataID, formcode: pmodel.FormCode }, function (result) {
                    var result = $.parseJSON(result)
                    if ($.trim(result.ErrorMsg) == "") {
                        ComFunJS.winsuccess("处理成功");
                        setTimeout("location.reload()", 500)

                    }
                });
            },
            transferform: function () {//转审
                if ($("#conshr1").val()) {
                    $.post("/API/FTAPI.ashx?ACTION=MANAGEWF", { P1: pmodel.PIID, P2: pmodel.spReason, SHUser: $("#conshr1").val(), ID: pmodel.DataID, formcode: pmodel.FormCode }, function (result) {
                        var result = $.parseJSON(result)
                        if ($.trim(result.ErrorMsg) == "") {
                            ComFunJS.winsuccess("转审成功");
                            setTimeout("location.reload()", 1000)
                        }
                    });
                } else {
                    ComFunJS.winwarning("请选择审核人");
                }
            },
            qx: function () {
                parent.layer.closeAll();
            },
            jptj: function (event, dom) {
                if (event.ctrlKey && (event.keyCode == 13 || event.keyCode == 10)) {
                    pmodel.SaveData(dom.find(".btnSucc")[0], true);
                }
            },
            DELPIINFO: function (PIID) {
                $.post("/API/FTAPI.ashx?ACTION=DELPIINFO", { P1: PIID }, function (result) {
                    var result = $.parseJSON(result)
                    if ($.trim(result.ErrorMsg) == "") {
                    }
                });
            }
        })
        avalon.ready(function () {
            ComFunJS.initsetajax();
       
        })
    </script>
</head>
<body ms-controller="APP_ADD" ms-keypress="jptj(event,$(this))">
    <div class="container-fluid" style="margin-top: 20px;margin-bottom:60px" ms-include-src="/View/TempHTML/{{FormCode}}.html" data-include-rendered='render'>
    </div>
    <table class="table navbar-fixed-bottom" style="background-color: #F3F6F8;">
        <tbody>
            <tr class="wfdata" ms-if="TASKDATA.size()!=0">
                <td>
                    <ul class="list-inline">
                        <li class="text-center" style="border-right: 1px solid #1B9AF7" ms-repeat-item="TASKDATA"> 
                            <div ms-if="lctype==1">{{item.TaskAssInfo}}[{{item.TaskName}}]</div>
                            <div>{{item.userrealname}}</div>
                            <div ms-if="item.EndTime">【{{item.EndTime}}】 {{item.TaskUserView}}</div>
                            <div ms-if="!item.EndTime&&PIMODEL.IsCanceled!='Y'&&PIMODEL.IsCanceled!='Y'"><i class="iconfont icon-shezhichilun fa-spin"></i> 等待处理</div>
                        </li>
                    </ul>
                </td>
            </tr>
            <tr class="trss" ms-if="!PIID&&pageType!='view'">
                <td class="text-center">
                    <div class="input-group" style="height:40px">
                        <span class="input-group-addon " ms-if="lctype=='0'">审核人</span>
                        <select class="form-control " style="height:40px;" id="conshr" ms-if="lctype=='0'">
                            <!--不是编辑页面并且是自由流程时才显示审核人选项-->
                            <option value="">选择审核人</option>
                            <option ms-repeat-item="USERDATA" ms-attr-value="item.UserName">{{item.UserRealName}}</option>
                        </select>
                        <span class="input-group-btn">
                            <button class="btn btn-danger btnqx" ms-click="qx()" style="width:80px;height:40px;">取消</button>
                            <button class="btn btn-success btnSucc" style="width:120px;height:40px;" ms-click="SaveData(this,false)" title="按CTRL+ENTER快速提交"><i class="fa fa-spinner fa-spin" style="display:none"></i> 保存数据</button>
                        </span>
                    </div>
                </td>
            </tr>
            <tr class="trss" ms-if="pageType=='edit'">
                <td class="text-center">
                    <div class="input-group" style="height:40px">
                        <span class="input-group-btn">
                            <button class="btn btn-danger btnqx" ms-click="qx()" style="width:80px;height:40px;">取消</button>
                            <button class="btn btn-success btnSucc" style="width:120px;height:40px;" ms-click="SaveData(this,false)" title="按CTRL+ENTER快速提交"><i class="fa fa-spinner fa-spin" style="display:none"></i> 保存数据</button>
                        </span>
                    </div>
                </td>
            </tr>
            <tr class="trsp" ms-if="iscansp">
                <td class="text-center ">
                    <div class="input-group" style="height:40px">
                        <span class="input-group-addon">处理意见</span>
                        <select class="form-control" style="height:40px;width:20%" id="conshr1" ms-if="lctype=='0'">
                            <!--是自由流程时才显示审核人选项-->
                            <option value="">选择转审人</option>
                            <option ms-repeat-item="USERDATA" ms-attr-value="item.UserName">{{item.UserRealName}}</option>
                        </select>
                        <input type="text" placeholder="此处填写处理意见,按ENTER键签核通过" ms-duplex="spReason" style="height:40px;width:80%" class="form-control szhl_require">
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-danger" ms-click="rebackform()" style="height:40px;width:120px">退回</button>
                            <button type="button" class="btn btn-info" ms-click="transferform()" style="height:40px;width:120px" ms-if="lctype=='0'">转审</button>
                            <button type="button" class="btn btn-success" ms-click="managetask()" style="height:40px;width:120px">审核通过</button>
                        </span>
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
    <link href="/JqueryPlug/umeditor122/themes/default/css/umeditor.css" type="text/css" rel="stylesheet" />
    <script src="/JqueryPlug/umeditor122/umeditor.js" type="text/javascript" charset="utf-8"></script>
    <script src="/JqueryPlug/umeditor122/umeditor.config.js" type="text/javascript" charset="utf-8"></script>
</body>
</html>